package com.ogawa.projectcommon.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.LogUtils;
import com.ogawa.projectcommon.bean.ProjectConfigWifiDeviceBean;
import com.ogawa.projectcommon.bean.ProjectUserInfoBean;
import com.ogawa.base.utils.ACacheUtils;

public class ProjectSpUtils {
    //用户信息
    static private String USER_INFO = "USER_INFO";
    static private String USER_INFO_STR = "USER_INFO_STR";
    //当前配置Wifi设备的参数保存
    static private String NET_DEVICE_CONFIG_INFO = "NET_DEVICE_CONFIG_INFO";
    //从设备管理中选择的当前设备类型
    static private String CUR_DEVICE_TYPECODE = "CUR_DEVICE_TYPECODE";

    //------------------获取用户信息------------------//
    /*
     *    退出登录
     */
    public static void userInfoLoginOut(){
        ACacheUtils.putString(USER_INFO_STR,"");
    }

    /*
     *    获取用户信息
     */
    public static ProjectUserInfoBean getUserInfo() {
        String string = ACacheUtils.getString(USER_INFO_STR, "");
        ProjectUserInfoBean projectUserInfoBean = GsonUtils.fromJson(string, ProjectUserInfoBean.class);
        if (projectUserInfoBean == null){
            projectUserInfoBean = new ProjectUserInfoBean();
        }
        return projectUserInfoBean;
//        return (ProjectUserInfoBean) ACacheUtils.getObject(USER_INFO, new ProjectUserInfoBean());
    }

    /*
     *    设置用户信息
     */
    public static void setUserInfo(ProjectUserInfoBean userInfo) {
//        ACacheUtils.putObject(USER_INFO,userInfo);
        ACacheUtils.putString(USER_INFO_STR,GsonUtils.toJson(userInfo));
    }



    //------------------当前配置wifi椅子的参数保存ProjectConfigWifiDeviceBean------------------//
    public static ProjectConfigWifiDeviceBean getProjectConfigWifiDeviceBean() {
        return (ProjectConfigWifiDeviceBean) ACacheUtils.getObject(NET_DEVICE_CONFIG_INFO, new ProjectConfigWifiDeviceBean());
    }

    public static void setProjectConfigWifiDeviceBean(ProjectConfigWifiDeviceBean userInfo) {
        ACacheUtils.putObject(NET_DEVICE_CONFIG_INFO,userInfo);
    }

    //------------------从设备管理中选择的当前设备类型------------------//
    public static String getCurDeviceTypeCode() {
        return ACacheUtils.getString(CUR_DEVICE_TYPECODE, "");
    }

    public static void setCurDeviceTypeCode(String deviceTypeCode) {
        ACacheUtils.putString(CUR_DEVICE_TYPECODE,deviceTypeCode);
    }




}
